package com.fz.us.admin.company.service;

import com.fz.us.admin.base.bean.BaseEnumManager;
import com.fz.us.admin.base.bean.Result;
import com.fz.us.admin.base.bean.search.order.Order;
import com.fz.us.admin.base.bean.search.page.PagePaging;
import com.fz.us.admin.base.bean.search.result.SearchResultList;
import com.fz.us.admin.base.bean.search.result.SearchResultPaging;
import com.fz.us.admin.base.bean.search.rule.Rule;
import com.fz.us.admin.base.service.BaseService;
import com.fz.us.admin.company.entity.*;

import java.util.List;
import java.util.Map;

/**
 * Service接口 - 职位
 * ============================================================================
 * 版权所有 2016 。
 *
 * @author fallenpanda
 * @version 1.0 2016-08-02 。
 * ============================================================================
 */
public interface DutyService extends BaseService<Duty, String> {

    /**
     * 用户默认职责Duty
     *
     */
    public Duty getDefaultDuty(User user);

    /**
     * 是否存在职权
     *
     * @param power
     * @return
     */
    public boolean hasPower(Power power);



    /**
     * 部门是否已分配人员
     *
     * @param department
     * @return
     */
    public boolean hasDepartment(Department department);

    /**
     * 用户是否已存在默认职权
     *
     * @param user
     * @return
     */
    public boolean hasMainDuty(User user);

    /**
     * 用户职权
     *
     * @param user
     * @return
     */
    public List<Duty> getUserDutyList(User user);

    /**
     * 用户默认职权
     *
     * @param user
     * @return
     */
    public Duty getUserDefaultDuty(User user);

    /**
     * 职权下用户
     *
     * @param power
     * @return
     */
    public List<Duty> getDutyListByPower(Power power);

    /**
     * 部门获得职责
     *
     * @param department
     * @return
     */
    public List<Duty> getDutyListByDepartment(Department department);



    /**
     * 岗位获得职责
     *
     * @param post
     * @return
     */
    public List<Duty> getDutyListByPost(Post post);

    /**
     * 职权获得用户
     *
     * @param power
     * @return
     */

    public List<User> getPowerUserList(Power power);

    /**
     * 部门获得用户
     *
     * @param department
     * @return
     */
    public List<User> getDepartmentUserList(Department department);


    /**
     * 岗位获得用户
     *
     * @param post
     * @return
     */
    public List<User> getPostUserList(Post post);

    /**
     * 设置用户默认职权
     */
    public Result setMainDuty(User user, Duty duty);

    /**
     * 清除用户默认职权
     */
    public Result removeMainDuty(User user);

    /**
     * 保存
     *
     * @param user
     * @param duty
     * @return
     */
    public Result createEntity(User user, Duty duty);

    /**
     * 修改
     *
     * @param user
     * @param duty
     * @return
     */
    public Result updateEntity(User user, String keyId, Duty duty);

    /**
     * 操作
     *
     * @param user
     * @param method
     * @param keyId
     * @return
     */
    public Result methodEntity(User user, String method, String keyId);

    /**
     * 分页 部门
     *
     * @param page
     * @param order
     * @return
     */
    public SearchResultPaging pagingDuty(PagePaging page, List<Rule> rules, Order order, Company company, BaseEnumManager.StateEnum... states);

    /**
     * 列表 部门
     *
     * @param order
     * @return
     */
    public SearchResultList listDuty(List<Rule> rules, Order order, Company company, BaseEnumManager.StateEnum... states);


    /**
     * 分页 部门成员
     *
     * @param page
     * @param order
     * @param department
     * @return
     */
    public SearchResultPaging pagingDuty(PagePaging page, List<Rule> rules, Order order, Company company, Department department, BaseEnumManager.StateEnum... states);

    /**
     * 列表 部门成员
     *
     * @param order
     * @param department
     * @return
     */
    public SearchResultList listDuty(List<Rule> rules, Order order, Company company, Department department, BaseEnumManager.StateEnum... states);

    /**
     * 分页 成员职权
     *
     * @param page
     * @param order
     * @param user
     * @return
     */
    public SearchResultPaging pagingDuty(PagePaging page, List<Rule> rules, Order order, Company company, User user, BaseEnumManager.StateEnum... states);

    /**
     * 列表 成员职权
     *
     * @param order
     * @param user
     * @return
     */
    public SearchResultList listDuty(List<Rule> rules, Order order, Company company, User user, BaseEnumManager.StateEnum... states);

    /**
     * 列表 Map
     *
     * @param duty
     * @return
     */
    public Map<String, Object> getListMap(Duty duty);

    /**
     * 详情 Map
     *
     * @param duty
     * @return
     */
    public Map<String, Object> getDetailMap(Duty duty);




    /**
     * 用户所属所有部门
     *
     */
    public List<Department> getDepartments(User user, Company company);

    /**
     * 根据用户获得职责
     * @param user
     * @return
     */
    public List<Duty> getDutys(User user);

    /**
     * 获取部门下的职责清单
     * */
    public List<Duty> getDutys(Department department);

    /**
     * 获取部门下的多个用户职责
     * */
    public List<Duty> getDutys(Department department, User user);
    /**
     * 用户负责的所属所有部门
     *
     */
    public List<Department> getPrincipalDepartments(User user);

    /**
     * 用户某个岗位所属所有部门
     *
     */
    public List<Department> getDepartments(User user, Post post);

    /**
     * 获取部门下所有用户
     *
     * @return 用户列表
     */
    public List<User>  getPersons(Department department);
    /**
     * 获取部门、岗位下所有用户
     *
     * @return 用户列表
     */
    public List<User>  getPersons(Department department, Post post);
    /**
     * 获取部门负责人
     *
     * @return 用户列表
     */
    public User getPrincipal(Department department);

    /**
     * 用户上级部门负责人
     *
     */
    public Duty getParentPrincipal(Department department);

    /**
     * 获取部门领导人的职责
     * @param department
     * @return
     */
    public Duty getPrincipalDuty(Department department);
}
